package br.com.candiolli.apoio.server;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.codehaus.jettison.json.JSONObject;

@Path("/carroWs")
public class CarroWS {

	@GET
	@Path("/get")
	@Produces(MediaType.TEXT_PLAIN)
	public String sayPlainTextHello() {
		return "Hello Jersey - ";
	}

	@POST
	@Path("/post")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public JSONObject  save(JSONObject inputJsonObj) {
		try {
			String input = (String) inputJsonObj.get("input");
			String output = "The input you sent is :" + input;
			JSONObject outputJsonObj = new JSONObject();
			outputJsonObj.put("output", output);
			return outputJsonObj;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
